home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / SASC_6.0_Disk_4.adf / Compiler_Headers / Include / dos / rdargs.h < prev    next >
C/C++ Source or Header  |  1992-07-30  |  4KB  |  127 lines

  1. #ifndef DOS_RDARGS_H
  2. #define DOS_RDARGS_H
  3. /*
  4. **
  5. **    $Filename: dos/rdargs.h $
  6. **    $Release: 2.04 Includes, V37.4 $
  7. **    $Revision: 36.6 $
  8. **    $Date: 90/07/12 $
  9. **
  10. **    ReadArgs() structure definitions
  11. **
  12. **    (C) Copyright 1989-1991 Commodore-Amiga, Inc.
  13. **        All Rights Reserved
  14. **
  15. */
  16.  
  17. #ifndef EXEC_TYPES_H
  18. #include "exec/types.h"
  19. #endif
  20.  
  21. #ifndef EXEC_NODES_H
  22. #include "exec/nodes.h"
  23. #endif
  24.  
  25. /**********************************************************************
  26.  *
  27.  * The CSource data structure defines the input source for "ReadItem()"
  28.  * as well as the ReadArgs call.  It is a publicly defined structure
  29.  * which may be used by applications which use code that follows the
  30.  * conventions defined for access.
  31.  *
  32.  * When passed to the dos.library functions, the value passed as
  33.  * struct *CSource is defined as follows:
  34.  *    if ( CSource == 0)    Use buffered IO "ReadChar()" as data source
  35.  *    else            Use CSource for input character stream
  36.  *
  37.  * The following two pseudo-code routines define how the CSource structure
  38.  * is used:
  39.  *
  40.  * long CS_ReadChar( struct CSource *CSource )
  41.  * {
  42.  *    if ( CSource == 0 )    return ReadChar();
  43.  *    if ( CSource->CurChr >= CSource->Length )    return ENDSTREAMCHAR;
  44.  *    return CSource->Buffer[ CSource->CurChr++ ];
  45.  * }
  46.  *
  47.  * BOOL CS_UnReadChar( struct CSource *CSource )
  48.  * {
  49.  *    if ( CSource == 0 )    return UnReadChar();
  50.  *    if ( CSource->CurChr <= 0 )    return FALSE;
  51.  *    CSource->CurChr--;
  52.  *    return TRUE;
  53.  * }
  54.  *
  55.  * To initialize a struct CSource, you set CSource->CS_Buffer to
  56.  * a string which is used as the data source, and set CS_Length to
  57.  * the number of characters in the string.  Normally CS_CurChr should
  58.  * be initialized to ZERO, or left as it was from prior use as
  59.  * a CSource.
  60.  *
  61.  **********************************************************************/
  62.  
  63. struct CSource {
  64.     UBYTE    *CS_Buffer;
  65.     LONG    CS_Length;
  66.     LONG    CS_CurChr;
  67. };
  68.  
  69. /**********************************************************************
  70.  *
  71.  * The RDArgs data structure is the input parameter passed to the DOS
  72.  * ReadArgs() function call.
  73.  *
  74.  * The RDA_Source structure is a CSource as defined above;
  75.  * if RDA_Source.CS_Buffer is non-null, RDA_Source is used as the input
  76.  * character stream to parse, else the input comes from the buffered STDIN
  77.  * calls ReadChar/UnReadChar.
  78.  *
  79.  * RDA_DAList is a private address which is used internally to track
  80.  * allocations which are freed by FreeArgs().  This MUST be initialized
  81.  * to NULL prior to the first call to ReadArgs().
  82.  *
  83.  * The RDA_Buffer and RDA_BufSiz fields allow the application to supply
  84.  * a fixed-size buffer in which to store the parsed data.  This allows
  85.  * the application to pre-allocate a buffer rather than requiring buffer
  86.  * space to be allocated.  If either RDA_Buffer or RDA_BufSiz is NULL,
  87.  * the application has not supplied a buffer.
  88.  *
  89.  * RDA_ExtHelp is a text string which will be displayed instead of the
  90.  * template string, if the user is prompted for input.
  91.  *
  92.  * RDA_Flags bits control how ReadArgs() works.  The flag bits are
  93.  * defined below.  Defaults are initialized to ZERO.
  94.  *
  95.  **********************************************************************/
  96.  
  97. struct RDArgs {
  98.     struct    CSource RDA_Source;    /* Select input source */
  99.     LONG    RDA_DAList;        /* PRIVATE. */
  100.     UBYTE    *RDA_Buffer;        /* Optional string parsing space. */
  101.     LONG    RDA_BufSiz;        /* Size of RDA_Buffer (0..n) */
  102.     UBYTE    *RDA_ExtHelp;        /* Optional extended help */
  103.     LONG    RDA_Flags;        /* Flags for any required control */
  104. };
  105.  
  106. #define RDAB_STDIN    0    /* Use "STDIN" rather than "COMMAND LINE" */
  107. #define RDAF_STDIN    1
  108. #define RDAB_NOALLOC    1    /* If set, do not allocate extra string space.*/
  109. #define RDAF_NOALLOC    2
  110. #define RDAB_NOPROMPT    2    /* Disable reprompting for string input. */
  111. #define RDAF_NOPROMPT    4
  112.  
  113. /**********************************************************************
  114.  * Maximum number of template keywords which can be in a template passed
  115.  * to ReadArgs(). IMPLEMENTOR NOTE - must be a multiple of 4.
  116.  **********************************************************************/
  117. #define MAX_TEMPLATE_ITEMS    100
  118.  
  119. /**********************************************************************
  120.  * Maximum number of MULTIARG items returned by ReadArgs(), before
  121.  * an ERROR_LINE_TOO_LONG.  These two limitations are due to stack
  122.  * usage.  Applications should allow "a lot" of stack to use ReadArgs().
  123.  **********************************************************************/
  124. #define MAX_MULTIARGS        128
  125.  
  126. #endif /* DOS_RDARGS_H */
  127.